package ai.fabu.dataplatform.bean.user;

import ai.fabu.dataplatform.utils.TimeUtil;
import lombok.Setter;
import lombok.Value;
import lombok.experimental.NonFinal;
import org.bson.types.ObjectId;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;

import javax.validation.constraints.NotBlank;
import java.util.HashMap;
import java.util.Map;

import static ai.fabu.dataplatform.constant.ConstantName.CREATE_TIME;
import static ai.fabu.dataplatform.constant.ConstantName.UPDATE_TIME;

@Value
@Document(collection = "user")
public class User {
    public static User staticUser(@NotBlank String userName, @NotBlank String password){
        return new User(null, userName, password, new HashMap<>(), new HashMap<>(), new HashMap<>(), TimeUtil.getNowTimestampLong(), TimeUtil.getNowTimestampLong());
    }

    @Setter
    @NonFinal
    @Id
    ObjectId userId;
    @Field("user_name")
    String userName;
    String password;
    @Field("last_task")
    Map<String, Object> lastTask;
    @Field("ongoing_task")
    Map<String, Object> ongoingTask;
    @Field("complete_task")
    Map<String, Object> completeTask;
    @Field(CREATE_TIME)
    Long createTime;
    @Field(UPDATE_TIME)
    Long updateTime;
}
